home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1122 / 1122.xpi / chrome / tabmixplus.jar / content / tabmixplus / extensions / sage.js next >
Text File  |  2009-08-30  |  2KB  |  52 lines

  1. // prevent Sage from load pages in locked tabs
  2. // code by onemen
  3.  
  4. const OPEN_TAB_FOR_SAGE = "extensions.tabmix.opentabfor.sage";
  5.  
  6. var TMP_Sage = {
  7.    init: function () {
  8.       eval("updateItemContextMenu ="+updateItemContextMenu.toString().replace(
  9.          'readStateController.onCommandUpdate();',
  10.          '$& TMP_Sage.buildContextMenu();'
  11.       ));
  12.  
  13.       eval("bookmarksTreeClick ="+bookmarksTreeClick.toString().replace(
  14.          'const BOOKMARK_SEPARATOR',
  15.          'var where = TMP_Places.fixWhereToOpen(aEvent, CreateHTML._tabbed ? "tab" : "current", TMP_Sage.openTabPref); \
  16.           CreateHTML.tabbed = where == "tab"; \
  17.           $&'
  18.       ));
  19.  
  20.       eval("bookmarksOpen ="+bookmarksOpen.toString().replace(
  21.          'getContentBrowser().loadURI(lastResource.url);',
  22.          'if (CreateHTML._tabbed) getContentBrowser().addTab(lastResource.url); \
  23.           else $&'
  24.       ));
  25.  
  26.       eval("openURI ="+openURI.toString().replace(
  27.          'switch (windowType)',
  28.          'windowType = TMP_Places.fixWhereToOpen((oType instanceof Event)? oType : null, !windowType ? "current" : windowType, TMP_Sage.openTabPref); \
  29.           $&'
  30.       ));
  31.  
  32.    },
  33.  
  34.    buildContextMenu: function () {
  35.       var _open = document.getElementById("rssOpenItem");
  36.       var _openInWindow = document.getElementById("rssOpenNewWindowItem");
  37.       var _openInTab = document.getElementById("rssOpenNewTabItem");
  38.       TMP_updateContextMenu(_open, _openInWindow, _openInTab, this.openTabPref);
  39.    },
  40.  
  41.    get openTabPref() {
  42.       var prefSVC = Components.classes["@mozilla.org/preferences-service;1"]
  43.                         .getService(Components.interfaces.nsIPrefBranch2);
  44.  
  45.       if (prefSVC.prefHasUserValue(OPEN_TAB_FOR_SAGE))
  46.          return OPEN_TAB_FOR_SAGE;
  47.       else
  48.          return prefStringTMBookmark;
  49.    }
  50.  
  51. }
  52.